//index.js
//获取应用实例
const app = getApp()

Page({
  data: {
    iscancel: false,
    motto: 'Hello World',
    userInfo: {},
    isuser: false,
    hasUserInfo: false,
    canIUse: wx.canIUse('button.open-type.getUserInfo'),
    username: '',
    password: '',
    errormsg: '',
    trueuserinfo: {
      username: 'fuxiangyou',
      password: '961948438'
    }
  },
  getusername(e){
    this.setData({ username: e.detail.value})
  },
  getpassword:function(e){
    this.setData({password: e.detail.value})
  },
  inputChange: function (e) {
    console.log(e)
    let prop = e.target.dataset['prop']
    let  obj =  {}
    obj[prop]  = e.detail.value,
    this.setData(obj)
  },
  tologin: function (e) {
    console.log(e)
    if (this.data.username == this.data.trueuserinfo.username && this.data.password == this.data.trueuserinfo.password) {
      this.setData({isuser: true, errormsg: ''})
    } else {
      this.setData({errormsg: '登录失败，用户密码不正确', isuser: false})
    }
  },
  cancel: function () {
    this.setData({ iscancel: !this.data.iscancel})
  }
})
